package com.example.teacherservice.dto;

import com.example.teacherservice.entity.Question;
import lombok.Data;
import java.time.LocalDateTime;

/**
 * 用户问题DTO（学生/教师通用）
 */
@Data
public class UserQuestionDTO {
    private Long id;
    private String content;
    private LocalDateTime createTime;  // 改为LocalDateTime
    private String questionType;
    private Long commentCount;
    private Boolean isStudent;

    // 添加转换方法
    public static UserQuestionDTO fromEntity(Question question) {
        UserQuestionDTO dto = new UserQuestionDTO();
        dto.setId(question.getId());
        dto.setContent(question.getContent());
        dto.setCreateTime(question.getCreateTime());
        dto.setQuestionType(question.getQuestionType());
        dto.setIsStudent(question.getStudentId() != null);
        return dto;
    }
}